package com.supermap.rootstock.data.source;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface SourceConfigMapper {

	@Select("select * from t_database")
	List<Map<String,Object>> getDataBase();

	@Select("select * from t_datasource_config where if(isnull(#{userId}),true,userid=#{userId})")
	List<Map<String,Object>> getDatatSourceConfig(@Param("userId") Integer userId);

	@Insert("insert into t_datasource_config(dsId,userId,name,ip,prot,sname,username,userpwd) values(#{dataSource.dsId},#{dataSource.userId}" +
		",#{dataSource.name},#{dataSource.ip}" +
		",#{dataSource.prot},#{dataSource.sname},#{dataSource.username},#{dataSource.userpwd})")
	Integer puttDatatSourceConfig(@Param("dataSource") DataSource dataSource);

	@Delete("delete from t_datasource_config where id=#{id}")
	Integer delDatatSourceConfig(@Param("id") Integer id);


}
